#include "../main.h"

#define CLASSNAME "Test"

struct T {
	pthread_t tid;
	
};

//DECLARE_CONSTRUCTOR();

IMPLEMENT_CONSTRUCTOR(__construct);


static JSBool __call (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval){
	struct T *x = JS_GetPrivate(cx, obj);
	char *text;
	JS_ConvertArguments(cx, argc, argv, "s", &text);
	*rval = atos(cx, "%s: zhop", CLASSNAME);
	return JS_TRUE;
}


static JSBool __get (JSContext *cx, JSObject *obj, jsval id, jsval *vp){
	trace1(CLASSNAME, "getProperty id=%s", stoa(cx, id));
	*vp = OBJECT_TO_JSVAL(obj);
	return JS_TRUE;
}

struct JSClass __class = {
	CLASSNAME, 
	JSCLASS_HAS_PRIVATE | JSCLASS_CONSTRUCT_PROTOTYPE,
	JS_PropertyStub, JS_PropertyStub, __get, JS_PropertyStub,
	JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
	NULL,
	NULL, __call
};

static JSFunctionSpec methods[] = {
	JS_FN("run",	Run,	0,0,0),
	JS_FN("fopen", 	Fopen, 	2,0,0),
	JS_FN("close", 	Close, 	1,0,0),
	JS_FN("popen", 	Popen, 	1,0,0),
	JS_FN("write", 	Write, 	2,0,0),
	JS_FN("read", 	Read, 	1,0,0),
	JS_FN("eof", 	Eof, 	1,0,0),
	JS_FN("flush", 	Flush, 	1,0,0),
	JS_FN("gets", 	Gets, 	1,0,0),
	JS_FS_END
};



int test_init(JSContext *cx, JSObject *global){
	JSObject *proto = JS_InitClass(cx, global, NULL, &__class, __construct, 0, NULL, NULL, NULL, NULL);
	return 0;
}










